
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>wsgi · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="vue整合.html" />
    
    
    <link rel="prev" href="ubuntu.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="redis.html">
            
                <a href="redis.html">
            
                    
                    redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="ubuntu.html">
            
                <a href="ubuntu.html">
            
                    
                    ubuntu
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4" data-path="wsgi.html">
            
                <a href="wsgi.html">
            
                    
                    wsgi
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="vue整合.html">
            
                <a href="vue整合.html">
            
                    
                    vue整合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="app打包.html">
            
                <a href="app打包.html">
            
                    
                    app打包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="numpy/preview.html">
            
                <a href="numpy/preview.html">
            
                    
                    numpy概览
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="numpy/numpy.html">
            
                <a href="numpy/numpy.html">
            
                    
                    创建数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="numpy/math.html">
            
                <a href="numpy/math.html">
            
                    
                    数组运算
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="numpy/operation.html">
            
                <a href="numpy/operation.html">
            
                    
                    数组操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="numpy/usea.html">
            
                <a href="numpy/usea.html">
            
                    
                    算法应用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >wsgi</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x9879;&#x76EE;&#x90E8;&#x7F72;">&#x9879;&#x76EE;&#x90E8;&#x7F72;</h1>
<h2 id="1-&#x9009;&#x62E9;&#x670D;&#x52A1;&#x5668;">1. &#x9009;&#x62E9;&#x670D;&#x52A1;&#x5668;</h2>
<h2 id="2-&#x5B89;&#x88C5;python&#x73AF;&#x5883;">2. &#x5B89;&#x88C5;python&#x73AF;&#x5883;</h2>
<ul>
<li>pip&#x5347;&#x7EA7;<pre><code>  python -m pip install -U[upgrade] pip
</code></pre><h2 id="3-&#x521B;&#x5EFA;&#x865A;&#x62DF;&#x73AF;&#x5883;">3. &#x521B;&#x5EFA;&#x865A;&#x62DF;&#x73AF;&#x5883;</h2>
</li>
<li>python -m venv myvenv</li>
<li>&#x5B89;&#x88C5;&#x76F8;&#x5E94;&#x7684;&#x5305;<pre><code>  1. pip freeze &gt; list.txt
  2. pip install -r list.txt
</code></pre></li>
<li>&#x5B89;&#x88C5; ssh<pre><code>  sudo apt-get update
  sudo apt-get install openssh-server
</code></pre></li>
<li>&#x5B89;&#x88C5;mysql<pre><code>  sudo apt-get install mysql-server mysql-client
</code></pre></li>
<li>&#x5B89;&#x88C5;redis<pre><code>  sudo apt-get install redis-server
</code></pre></li>
<li>&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;<pre><code>  DEBUG = False
  ALLOW_HOSTS=[&apos;*&apos;,]&#x8868;&#x793A;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x670D;&#x52A1;&#x5668;&#x7684;ip
</code></pre></li>
</ul>
<h2 id="4-&#x4E0A;&#x4F20;&#x4EE3;&#x7801;">4. &#x4E0A;&#x4F20;&#x4EE3;&#x7801;</h2>
<ul>
<li>scp source username@ipaddress:/home/..</li>
</ul>
<h2 id="5-&#x5BFC;&#x51FA;&#xFF0C;&#x5BFC;&#x5165;&#x6570;&#x636E;&#x5E93;">5. &#x5BFC;&#x51FA;&#xFF0C;&#x5BFC;&#x5165;&#x6570;&#x636E;&#x5E93;</h2>
<ul>
<li>&#x5BFC;&#x51FA;&#x6570;&#x636E;&#x5E93;<pre><code>  mysqldump -h localhost -u root -p mydb &gt; output
</code></pre></li>
<li>&#x5BFC;&#x5165;&#x6570;&#x636E;&#x5E93;<pre><code>  1. &#x521B;&#x5EFA;&#x76F8;&#x5E94;&#x7684;&#x6570;&#x636E;&#x5E93;
  2. source datafile
</code></pre></li>
<li><p>mysql &#x7528;&#x6237;&#x6388;&#x6743;</p>
<pre><code>  GRANT ALL PRIVILEGES ON *.* TO &apos;myuser&apos;@&apos;%&apos; IDENTIFIED BY &apos;mypassword&apos; WITH GRANT OPTION;

  FLUSH   PRIVILEGES;
</code></pre></li>
</ul>
<h2 id="6-&#x542F;&#x52A8;&#x670D;&#x52A1;&#x5668;">6. &#x542F;&#x52A8;&#x670D;&#x52A1;&#x5668;</h2>
<pre><code>```
python manager.py runserver
```
</code></pre><p>django manager.py runserver</p>
<h2 id="7-uwsgi">7. UWSGI</h2>
<ul>
<li>WSGI&#xFF1A;Web&#x670D;&#x52A1;&#x5668;&#x7F51;&#x5173;&#x63A5;&#x53E3;&#xFF0C;&#x82F1;&#x6587;&#x4E3A;Python Web Server Gateway Interface&#xFF0C;&#x7F29;&#x5199;&#x4E3A;WSGI&#xFF0C;&#x662F;Python&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6216;&#x6846;&#x67B6;&#x548C;Web&#x670D;&#x52A1;&#x5668;&#x4E4B;&#x95F4;&#x7684;&#x4E00;&#x79CD;&#x63A5;&#x53E3;&#xFF0C;&#x88AB;&#x5E7F;&#x6CDB;&#x63A5;&#x53D7;</li>
<li>uWSGI&#x5B9E;&#x73B0;&#x4E86;WSGI&#x7684;&#x6240;&#x6709;&#x63A5;&#x53E3;&#xFF0C;&#x662F;&#x529F;&#x80FD;&#x5B8C;&#x5584;&#x7684;&#x670D;&#x52A1;&#x5668;</li>
<li>uWSGI&#x4EE3;&#x7801;&#x5B8C;&#x5168;&#x7528;C&#x7F16;&#x5199;</li>
<li>&#x5B89;&#x88C5;uwsgi<pre><code>  pip install uwsgi
</code></pre></li>
<li>&#x5982;&#x679C;&#x5B89;&#x88C5;&#x5931;&#x8D25;,&#x8BF7;&#x5B89;&#x88C5;&#x4EE5;&#x4E0B;&#x4F9D;&#x8D56;<pre><code>  sudo apt-get install libpython3.x-dev
</code></pre></li>
<li>&#x914D;&#x7F6E;uwsgi(&#x5728;&#x9879;&#x76EE;&#x7684;&#x6839;&#x76EE;&#x5F55;&#x65B0;&#x5EFA; &#x6587;&#x4EF6;)<pre><code>  [uwsgi]
  socket=ipaddress:port&#xFF08;&#x548C;nginx&#x670D;&#x52A1;&#x5668;&#x914D;&#x5408;&#x65F6;&#xFF0C;&#x4F7F;&#x7528; socket&#xFF09;
  http=ipaddress:port&#xFF08;&#x76F4;&#x63A5;&#x505A;web&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x4F7F;&#x7528;http&#xFF09;
  chdir=&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;
  wsgi-file=&#x9879;&#x76EE;&#x4E2D;wsgi.py&#x6587;&#x4EF6;&#x7684;&#x76EE;&#x5F55;&#xFF0C;&#x76F8;&#x5BF9;&#x4E8E;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;
  processes=4
  threads=2
  master=True
  pidfile=uwsgi.pid
  daemonize=uswgi.log
</code></pre></li>
<li>&#x542F;&#x52A8;&#xFF1A;uwsgi --ini uwsgi.ini</li>
<li>&#x505C;&#x6B62;&#xFF1A;uwsgi --stop uwsgi.pid</li>
<li>&#x91CD;&#x542F;&#xFF1A;uwsgi --reload uwsgi.pid</li>
</ul>
<h2 id="8-nginx">8. nginx</h2>
<ul>
<li>&#x8D1F;&#x8F7D;&#x5747;&#x8861;,&#x53CD;&#x5411;&#x4EE3;&#x7406;&#x7684;&#x670D;&#x52A1;&#x5668;</li>
<li>&#x5B89;&#x88C5;<pre><code>  sudo apt-get install nginx
</code></pre><ul>
<li>&#x67E5;&#x770B;&#x7248;&#x672C;&#xFF1A;sudo nginx -v</li>
<li>&#x542F;&#x52A8;&#xFF1A;sudo nginx</li>
<li>&#x505C;&#x6B62;&#xFF1A;sudo nginx -s stop</li>
<li>&#x91CD;&#x542F;&#xFF1A;sudo nginx -s reload</li>
</ul>
</li>
<li>&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;<ul>
<li>/etc/nginx/nginx.conf</li>
<li>/etc/nginx/sites-enabled/default<pre><code>location / {
include uwsgi_params;&#x5C06;&#x6240;&#x6709;&#x7684;&#x53C2;&#x6570;&#x8F6C;&#x5230;uwsgi&#x4E0B;
uwsgi_pass uwsgi&#x670D;&#x52A1;&#x5668;&#x7684;ip&#x4E0E;&#x7AEF;&#x53E3;;
}
</code></pre></li>
<li>&#x4FEE;&#x6539;uwsgi.ini&#x6587;&#x4EF6;&#xFF0C;&#x542F;&#x52A8;socket&#xFF0C;&#x7981;&#x7528;http</li>
<li>nginx &#x4EE3;&#x7406;&#x5176;&#x4ED6;&#x8BBE;&#x7F6E;<pre><code>large_client_header_buffers 4 16k;
client_max_body_size 300m;
client_body_buffer_size 128k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 64k;
proxy_buffers   4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
root /var/www/project/static;
index index.html index.htm;
</code></pre></li>
</ul>
</li>
<li>&#x9759;&#x6001;&#x6587;&#x4EF6;&#x8BBE;&#x7F6E;<ul>
<li>&#x8BBE;&#x7F6E;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x4F4D;&#x7F6E;<pre><code>location /static {
alias /var/www/project/static/;
}
</code></pre></li>
<li>&#x5728;&#x6307;&#x5B9A;&#x4F4D;&#x7F6E;&#x521B;&#x5EFA;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF0C;&#x5E76;&#x4FEE;&#x6539;&#x6743;&#x9650;<pre><code>sudo chmod -R 777 /var/www/project
</code></pre></li>
<li>&#x4FEE;&#x6539;settings.py&#x6587;&#x4EF6;<pre><code>STATIC_ROOT=&apos;/var/www/project/static/&apos;
STATIC_URL=&apos;/static/
</code></pre></li>
<li>&#x91C7;&#x96C6;&#x6240;&#x6709;&#x9759;&#x6001;&#x6587;&#x4EF6;&#x5230;static_root&#x6307;&#x5B9A;&#x7684;&#x76EE;&#x5F55;<pre><code>python manage.py collectstatic
</code></pre></li>
<li>&#x91CD;&#x542F;uwsgi&#x548C;nginx</li>
</ul>
</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="ubuntu.html" class="navigation navigation-prev " aria-label="Previous page: ubuntu">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="vue整合.html" class="navigation navigation-next " aria-label="Next page: vue整合">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"wsgi","level":"1.4","depth":1,"next":{"title":"vue整合","level":"1.5","depth":1,"path":"vue整合.md","ref":"vue整合.md","articles":[]},"previous":{"title":"ubuntu","level":"1.3","depth":1,"path":"ubuntu.md","ref":"ubuntu.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["livereload"],"pluginsConfig":{"livereload":{},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"wsgi.md","mtime":"2018-08-22T01:30:34.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-02T04:20:29.430Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

